# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=geocode-glib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.20.1
pkgrel=1
arch=('any')
pkgdesc="geocoding and reverse geocoding GLib library using Yahoo! Place Finder (mingw-w64)"
license=("LGPL 2")
url="https://www.gnome.org/"
install=${_realname}-${CARCH}.install
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-json-glib"
         "${MINGW_PACKAGE_PREFIX}-libsoup")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            "gtk-doc"
            "make"
            "libtool"
            "automake-wrapper"
            "autoconf"
            "gettext"
            "patch")
options=('strip' '!debug' 'staticlibs')
source=(https://download.gnome.org/sources/${_realname}/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz
        001-locale.patch)
sha256sums=('669fc832cabf8cc2f0fc4194a8fa464cdb9c03ebf9aca5353d7cf935ba8637a2'
            '7379362319bab800b464ae4cf1d33e05f51bf500d8b0f65be63c05036f040c34')

prepare() {
  cd ${_realname}-${pkgver}

  patch -p1 -i ${srcdir}/001-locale.patch

  autoreconf -fi
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  mkdir -p docs/html
  cp -rf ../${_realname}-${pkgver}/docs/html/* docs/html

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LIB" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LIB"
}
